<?php
function findLikeNum($objId){
	include ("conn.php");
	$sql="SELECT COUNT(*) FROM likeList WHERE objId='".$objId."'";
	$result = $conn->query($sql);
	$row = $result->fetch_assoc();
	return (int)$row['COUNT(*)'];
}
function setLikeNum($uid,$objId,$mode,$increment){
	include ("conn.php");
	$nowLikeNum=findLikeNum($objId);
	$newLikeNum = $nowLikeNum + $increment;
	if($mode == "1"){
		$sql="UPDATE pageList 
		SET likeNum=".$newLikeNum." 
		WHERE id=".$objId;	
	}else{
		$objIdDecode = json_decode($objId);
		$pid = $objIdDecode[0];
		$pcoid = $objIdDecode[1];
		$sql="UPDATE comment 
		SET likeNum=".$newLikeNum." 
		WHERE pid=".$pid." AND pcoid=".$pcoid;
	}
	$result = $conn->query($sql);
	return;
}
?>